package com.xianggu.tomcat.servlet;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author chengjy
 * @date 2025/3/6
 */
public class ErrDefaultServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletOutputStream outputStream = resp.getOutputStream();
        outputStream.write("404 访问资源不存在！".getBytes());
        resp.setStatus(404, "404 访问资源不存在！");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletOutputStream outputStream = resp.getOutputStream();
        outputStream.write("404 访问资源不存在！".getBytes());
        resp.setStatus(404, "404 访问资源不存在！");
    }

    @Override
    protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletOutputStream outputStream = resp.getOutputStream();
        outputStream.write("404 访问资源不存在！".getBytes());
        resp.setStatus(404, "404 访问资源不存在！");
    }

    @Override
    protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletOutputStream outputStream = resp.getOutputStream();
        outputStream.write("404 访问资源不存在！".getBytes());
        resp.setStatus(404, "404 访问资源不存在！");
    }
}
